package com.jiyun.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jiyun.entity.Goods;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 聪哥哥
 * @since 2023-02-20
 */
public interface GoodsMapper extends BaseMapper<Goods> {


    @Select("SELECT \n" +
            "g.*\n" +
            "from goods g,huodong_goods hg\n" +
            "where g.id = hg.gid and hg.hid = #{hid}")
    List<Goods> findGoodsByHid(@Param("hid") Integer hid);


    @Update("update goods set stock = stock-1 where id=#{id}")
    void koujiankucun(@Param("id") Integer id);
}
